<?php
/**
 * Demo Model
 * @author wangji <j@wj45.net>
 */

class caModel
{
    private $_db;
    
    public function __construct() {
        $this->_db = new DB();
    }

	public function getCategoryTree($root) {
		$db=$this->_db;
		$tree=array();
		$father=$db->get_all("select * from category where father=0 and root !=0");
			
		foreach($father as $item) {
			$node['father']=$item;
			$node['child']=$db->get_all("select * from category where father=${item['id']}");
			array_push($tree, $node);
		}
		return $tree;
	}
}

/* ------ EOF ------ */
